<template>
    <div>
        <el-button class="fr" type="primary" size="small" @click="detail">统计详情</el-button>
        <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item to="/user/page">用户列表</el-breadcrumb-item>
            <el-breadcrumb-item>用户详情</el-breadcrumb-item>
            <el-breadcrumb-item>配置客户列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-table :data="tableData" border stripe class="mt15">
            <el-table-column type="index"></el-table-column>
            <el-table-column prop="code" label="编号" sortable></el-table-column>
            <el-table-column prop="user" label="用户" sortable></el-table-column>
            <el-table-column prop="currency" label="币种" sortable></el-table-column>
            <el-table-column prop="enabled" label="状态" sortable>
                <template scope="scope">{{scope.row.enabled | dict('ENABLED', $store.state.dict.list)}}</template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
    import axios from '~plugins/axios';

    export default {
        layout: 'admin',
        head() {
            return {
                title: '配置客户列表'
            };
        },
        data() {
            return {
                tableData: []
            };
        },
        async asyncData({query}) {
            return axios.get(`/api/agent/list/${query.id}`).then(res => {
                return {
                    tableData: res.data
                };
            });
        },
        methods: {
            detail() {
                this.$router.push({path: '/user/allocation/statistics', query: {id: this.$route.query.id}});
            },
            assetsDetail(row, expanded) {
                if (expanded) {
                    axios.get(`/api/agent/detail/${row.code}`).then(res => {
                        this.detail = res.data;
                    });
                }
            }
        }
    };
</script>